Finding a contour of an object (i.e., the object's border or outline) in a digital image is often the first step in many image-analysis applications, such as object detection or object classification. Given a preprocessed version of the image, many current contour-extraction methods identify an edge pixel and search the area of the image nearby for another, connected edge pixel. The area searched may include the four pixels connected to a side of the current edge pixel (i.e., the “four-connected neighbors”) or the eight pixels connected via both sides and corners (i.e., the “eight-connected neighbors”). By repeatedly searching for more connected edge pixels, a contour may be traced by traversing the edge, wherever in the image it leads, in a clockwise or counter-clockwise direction. As more edge pixels are found, they may be added to a list of pixels belonging to the contour. This process is continued until the first identified edge pixel is encountered again (i.e., the entire contour is traced).
While this technique may find the contours present in an image, it may run quite slowly on some processors. Because the edge path may travel in any direction, and because this direction cannot be predicted, pixels from any portion of the image may need to be analyzed as the algorithm works. Many processors (especially low-power or digital-signal processors) are unable to store an entire image in local, fast memory and must therefore load necessary portions of the image from external, slow memory as they are needed. These memory accesses may significantly retard the operation of the algorithm. Other algorithms may process the digital image in a more deterministic fashion (e.g., by marching across the pixels in the image), but these methods are typically incapable of fully identifying the contours of complex shapes. A need therefore exists for a way to detect contours of arbitrary shapes in a digital image in a manner that runs efficiently on a processor having a small local memory.